package org.easy.file;

import lombok.Getter;

import java.util.Arrays;

/**
 * 文件任务状态码
 *      1:运行成功
 *      2:任务已经存在
 *      3:线程异常
 *      4:
 *      5:
 *      6:
 *      7:
 * @author wuxueli
 */
@Getter
public enum FileTaskStatusCode {
    /**
     *
     */
    CODE_1(1,"运行成功"),
    CODE_2(2,"任务已经存在"),
    CODE_3(3,"线程异常"),
    CODE_4(4,""),
    CODE_5(5,""),
    CODE_6(6,""),
    CODE_7(7,"");

    private final Integer code;

    private final String msg;

    FileTaskStatusCode(Integer code,String msg){
        this.code = code;
        this.msg = msg;
    }

    public static String getMsg(Integer code){
        return Arrays.stream(FileTaskStatusCode.values())
                .filter(f -> f.getCode().equals(code))
                .findAny()
                .orElseThrow(() -> new IllegalArgumentException("参数不合法......"))
                .getMsg();
    }

}
